import { PageParams, PageResult } from "@/types/common"
import request from "@/utils/request"
import { DishListResult, DishResult, DishWithFlavorsResult } from "@/types/dish";
/**
 * 菜品分页查询
 * @param params 
 * @returns 
 */
type DishPageParams = PageParams & {
  businessId?: number
  name?: string;
  categoryId?: number;
  status?: number;
};
export const getAdminDishPageAPI = (params: DishPageParams) => {
  return request<PageResult<DishResult[]>>({
    method: 'GET',
    url: '/admin/dish/page',
    params
  })
}
/**
 * 菜品起售、停售
 * @param status 
 * @returns 
 */
export const postAdminDishStatusAPI = (status: number, id: number) => {
  return request({
    method: 'POST',
    url: `/admin/dish/status/${status}`,
    params: { id }
  })
}
/**
 * 根据id查询菜品
 * @param id 
 * @returns 
 */
export const getAdminDishAPI = (id: number) => {
  return request<DishWithFlavorsResult>({
    method: 'GET',
    url: `/admin/dish/${id}`
  })
}
/**
 * 根据分类id查询菜品
 * @param categoryId 
 * @returns 
 */
export const getAdminDishListAPI = (categoryId: number) => {
  return request<DishListResult[]>({
    method: 'GET',
    url: '/admin/dish/list',
    params: { categoryId }
  })
}